#ifndef BOARD_I2C_H
#define BOARD_I2C_H 1

#include "stm32f10x.h"
#include "I2CRoutines.h"
#include "board_timer.h"
#include "board_NVIC.h"


#if 0
#define I2C1_EV_PRIORITY 0
#define I2C1_ER_PRIORITY 1

#define I2C2_EV_PRIORITY 0
#define I2C2_ER_PRIORITY 1
#endif


/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
//#define SLAVE_DMA_USE
/* Private macro -------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
static volatile uint8_t Tx_Idx1=0, Rx_Idx1=0;
static volatile uint8_t Tx_Idx2=0, Rx_Idx2=0;
extern __IO  uint32_t NumbOfBytes1;
extern __IO  uint32_t NumbOfBytes2;
//extern uint8_t Buffer_Rx1[];
//extern uint8_t Buffer_Tx1[];
//extern uint8_t Buffer_Rx2[];
//extern uint8_t Buffer_Tx2[];





extern __IO uint32_t I2CDirection ;
extern uint8_t Address;

/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/





void I2C1_EV_IRQHandler(void);
void I2C1_ER_IRQHandler(void);
void I2C2_EV_IRQHandler(void);
void I2C2_ER_IRQHandler(void);

int32_t i2c_write(
                    uint8_t device_address,
                    uint8_t write_address,
                    uint8_t write_data
                 );
int32_t i2c_read(
                    uint8_t  device_address,
                    uint8_t  start_read_address,
                    uint32_t number_byte_to_read,
                    uint8_t* pointer_to_buffer  // pointer to bytes
                 );

void i2c_unstick(void);
void i2c_init(void);

#endif